package contestseeker.visitors;

import org.htmlparser.Tag;
import org.htmlparser.tags.TableRow;
import org.htmlparser.tags.TableTag;

public class NanKaiSeeker extends VisitorBase {
	public static final String NAME = "NanKai Recent Contests on Other OJs";
	public static final String URL = "http://acm.nankai.edu.cn/recent_contests.php";
	public static final String ENCODING = "GB2312";
	public static final String TITLE = "Recent Contests on Other OJs";

	public NanKaiSeeker() {
		super.URL = URL;
		super.ENCODING = ENCODING;
		super.TITLE = TITLE;
		super.NAME = NAME;
	}

	@Override
	public void visitTag(Tag tag) {
		if (tag instanceof TableTag) 
		{
			TableTag table = (TableTag) tag;
			if (table.getAttribute("class").compareTo("problem_list") == 0) 
			{
				TableRow row;
				this.beginTable(TITLE);
				this.addHeader(table.getRow(0));
				for (int i = 1; i < table.getRowCount(); ++i) {
					row = table.getRow(i);
					this.addColumns(row);
				}
				this.endTable();
			}
		}
	}
}
